package cn.silver.framework.web.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.io.Serial;
import java.io.Serializable;
import java.util.List;

@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
@Schema(name = "TreeModel", title = "树结果对象")
public class TreeModel implements Serializable {
    @Serial
    private static final long serialVersionUID = 1L;
    @Schema(title = "数据主键")
    private String id;
    @JsonIgnore
    @Schema(title = "上级主键")
    private String pid;
    @Schema(title = "业务编码")
    private String code;
    @Schema(title = "业务名称")
    private String name;
    @Schema(title = "节点值")
    private String key;
    @Schema(title = "节点名称")
    private String title;
    @Schema(title = "显示名称")
    private String label;
    @Schema(title = "显示名称")
    private String value;
    private Boolean hasChild;
    @Schema(title = "子元素")
    private List<TreeModel> children;

    public TreeModel(String id, String pid, String code, String name, String label) {
        this.id = id;
        this.pid = pid;
        this.code = code;
        this.name = name;
        this.key = this.id;
        this.title = label;
        this.value = id;
        this.label = label;
    }
}
